<template>
	<view style="position: relative;z-index: 99;">
		<youlanSignIn
		    :integral="integral"
		    :isIntegral="isIntegral" 
		    :checkinDays="checkinDays" 
		    :already="data" 
		    type="sign" 
		    lang="zh" 
		    @change="signDate" 
		/>
	</view>
</template>

<script>
	
	import { getSignList,postSignIntegral } from '@/api/user';
	
	import youlanSignIn from '@/components/youlan-SignIn/youlan-SignIn.vue'
	export default {
		components: {
		    youlanSignIn
		},
		name:"signIn",
		data() {
			return {
				   data: ["2024-12-03","2024-12-04"],
				        checkinDays: 0,     // 连续签到天数
				        integral: 0,        // 本次签到获取的积分
				        isIntegral: false,  // 是否显示签到积分模块
			};
		},
		onLoad() {
			console.log("this.getdata()")
		 this.getdata()
		},
		methods: {
			getdata(){
				let that = this
				getSignList(1,100).then(res=>{
					 this.checkinDays = res.data.length
					res.data.forEach(el => {
		            // 需要换成时间戳
		            that.data.push(new Date(el.createTime.substring(0,10)).getTime())
		        })
				})
	
			},
		    signDate(v) {
				postSignIntegral().then(res=>{
					// 模拟获取的积分,这个根据你的实际情况来，如果你没有积分系统，可以忽略这些
					this.integral = res.data.integral;
					this.isIntegral = true;
				})
		        console.log(v);
		    }
		}
		
	}
</script>

<style>

</style>